const UserStock = require('../db/model/user_stock');
const cryptoHelper = require('../helper/crypto');

const add = async (name, code, shortcut) => {

    let record = await UserStock.query().insert({
        user_id,
        stock_id,
        status,
        price,
        created_at,
        updated_at
    });

    return record;
};

const get = async (id) => {

    let record = await UserStock.query().findOne({id});

    return record;
};

const update = async (id, status, updated_at) => {

    let record = await UserStock.query().update({status, updated_at}).where("id", id);

    return record;
};

const remove = async (id) => {

    let record = await UserStock.query().where("id", id).del();

    return record;
};

//  REBOL todo, pager, limit
const list = async (user_id) => {

    let record = await UserStock.query().select().where("user_id", user_id);

    return record;
};

//  REBOL todo, update_batch, use python to write a tool to update price every day.

module.exports = {
    add,
    get,
    update,
    remove,
    list,
};